let uid = localStorage.getItem("uid");
console.log(uid);

if (uid) {
  document.querySelector('.box-log').style.display = "none";
  document.querySelector('.log-btn').innerHTML = '欢迎回来!';


  let url = 'http://jx.xuzhixiang.top/ap/api/cart-list.php';
  axios.get(url, {
    params: {
      id: uid
    },
  }).then(function (res) {
    console.log(res);
    let num = 0;
    if (res == null) {
      num = 0;
    } else {

      res.data.data.forEach(v => {
        num = num * 1 + v.pnum * 1;
      });
    }
    // console.log(num);
    document.querySelector('.Product-num').innerHTML = num;

  })
} else {
  document.querySelector('.box-log').style.display = "block";
  document.querySelector('.log-btn').innerHTML = '你好，请登录';
}

let quit = document.querySelector('.top-right li:nth-child(5)');
quit.onclick = function () {
  localStorage.removeItem("uid");
  location.href = "index.html";
}